console.log('导入是否正确：', axios, '===', Qs);

//#region qs的测试部分

let div1 = document.getElementById('div1');

let json = {
  id: 100,
  info: '黑暗骑士',
};

// qs的功能就是转换json为查询字符串（get提交数据的格式）
div1.innerHTML = Qs.stringify(json);

let query = "id=100&info=%E9%BB%91%E6%9A%97%E9%AA%91%E5%A3%AB";
console.log("还原查询字符串为json：",Qs.parse(query));

query = "pglt=161&q=黑暗骑士&cvid=b5ca2ddf78fe4c009cb87896c4501415&gs_lcrp=EgZjaHJvbWUyBggAEEUYOTIGCAEQABhAMgYIAhAAGEAyBggDEAAYQDIGCAQQABhAMgYIBRAAGEAyBggGEAAYQDIGCAcQABhAMgYICBBFGDzSAQgxNzM0ajBqMagCALACAA&FORM=ANNTA1&PC=U531"
console.log("还原查询字符串为json：",Qs.parse(query));

let txtecho = document.getElementById('txtecho');
let btnecho = document.getElementById('btnecho');
let divecho = document.getElementById('divecho');

const BASE_URL = 'https://api.huhuiyu.top';


btnecho.addEventListener('click', () => {
  let promise = axios({
    url: BASE_URL + '/test/echo?echo=' + txtecho.value,
    data:'',
    method:'get',
  });

  promise.then((resp)=>{
    // divecho.innerHTM = JSON.stringfy(resp.data);
    divecho.innerHTML =resp.data,data;
  }).catch((err)=>{
    console.error('应用程序异常:',err);
  } );
});

let btnFootball = document.getElementById('btnFootball');
let divFootball = document.getElementById('divFootball');

btnFootball.addEventListener('click', () =>{
  // json格式的参数
  let params = {
    orderBy:1,
    pageNumber:1,
    pageSize:5,
  };
  // 传唤参数为查询字符串格式
  let data = Qs.stringify(params);
  console.log('传递的数据：', data);
  // 发起请求
  let promise = axios({
    url:BASE_URL + '/crud/footballteam?' + data,
    data: '',
    method:'get',
  });

  promise.then((resp) => {
    divFootball.innerHTML = JSON.stringify(resp.data,null,2);
  }).catch((err) =>{
    console.error(err);
  });
});
// #endregion
//#endregion
